using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace hao_Common.Dapper.Repository
{
    /// <summary>
    /// 通用仓储接口，支持异步CRUD和软删除
    /// </summary>
    public interface IGenericRepository<T> where T : class, ISoftDelete
    {
        Task<T> GetByIdAsync(object id);
        Task<IEnumerable<T>> GetAllAsync();
        Task<IEnumerable<T>> FindAsync(Expression<Func<T, bool>> predicate);
        Task AddAsync(T entity);
        Task UpdateAsync(T entity);
        Task DeleteAsync(object id); // 软删除
        Task RemoveAsync(object id); // 真正物理删除
        
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageNumber">页码（从1开始）</param>
        /// <param name="pageSize">每页大小</param>
        /// <param name="orderBy">排序字段</param>
        /// <param name="isDescending">是否降序</param>
        /// <returns>分页结果</returns>
        Task<(IEnumerable<T> Items, int TotalCount)> GetPagedAsync(int pageNumber, int pageSize, string orderBy = "Id", bool isDescending = false);
    }

    /// <summary>
    /// 软删除接口，所有支持软删除的实体需实现
    /// </summary>
    public interface ISoftDelete
    {
        bool IsDeleted { get; set; }
    }
}